<template>
	<div>
		患者列表
		<el-tag  style="width: 200px;" size="mini">未诊</el-tag>
		<el-table :data="registList1"  style="width: 100%" size="mini" @row-click="selectRegister">
		      <el-table-column prop="id" label="id" >
		      </el-table-column>
		      <el-table-column  prop="name" label="姓名" >
		      </el-table-column>
		      <el-table-column prop="status" label="状态">
		      </el-table-column>
		</el-table>
		
		
		<el-tag style="width: 200px;" size="mini">已诊</el-tag>
		<el-table :data="registList2"  style="width: 100%"  size="mini" @row-click="selectRegister">
		      <el-table-column prop="id" label="id" >
		      </el-table-column>
		      <el-table-column  prop="name" label="姓名" >
		      </el-table-column>
		      <el-table-column prop="status" label="状态">
		      </el-table-column>
		</el-table>
		
		
	</div>
</template>

<script>
	//
	export default {
		name:'RegistList',
		props:["type"],
		data(){
			return {
				//初始化的时候查询所有的患者
				registList:[
				]
			}
		},
		methods:{
			selectRegister(register, column, event){
				console.log(register);
				this.$emit("changeRegister",register)
			}
		},
		computed:{
			//未诊  status = 1 
			registList1(){
				let list = this.registList.filter((regist)=>{
					return regist.status == 1
				})
				return list;
				
			},
			//已诊
			registList2(){
				let list = this.registList.filter((regist)=>{
					return regist.status == 2
				})
				return list;
			}
		},
		created() {
			//模拟数据库查询
			if(this.type == 1){
				//SELECT * FROM register t WHERE t.`doctor_id` = ?;
				this.registList = [
					{id:1,name:'个人张三',status:1},
					{id:2,name:'个人赵云',status:2},
					{id:3,name:'个人关于',status:1},
					{id:4,name:'个人诸葛亮',status:2},
					{id:5,name:'个人孙悟空',status:2},
					{id:6,name:'个人曹操',status:1},
				]
			}else{
				
				//访问网络   getList?type=2
				//SELECT * FROM register t WHERE t.`dept_id` = ? 
				this.registList = [
					{id:1,name:'部门张三',status:1},
					{id:2,name:'部门赵云',status:2},
					{id:3,name:'部门关于',status:1},
					{id:4,name:'部门诸葛亮',status:2},
					{id:5,name:'部门孙悟空',status:2},
					{id:6,name:'部门曹操',status:1},
				]
			}
			
		}
	}
	
</script>

<style>
</style>
